home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / TimeSchedulerdefs.h,v < prev    next >
Text File  |  1989-02-23  |  3KB  |  141 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.38.10;  author grunwald;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 3.2
  21. log
  22. @Start using Gnu library heaps for schedulers
  23. @
  24. text
  25. @// This may look like C code, but it is really -*- C++ -*-
  26. /* 
  27. Copyright (C) 1988 Free Software Foundation
  28.     written by Doug Lea (dl@@rocky.oswego.edu)
  29.  
  30. This file is part of GNU CC.
  31.  
  32. GNU CC is distributed in the hope that it will be useful,
  33. but WITHOUT ANY WARRANTY.  No author or distributor
  34. accepts responsibility to anyone for the consequences of using it
  35. or for whether it serves any particular purpose or works at all,
  36. unless he says so in writing.  Refer to the GNU CC General Public
  37. License for full details.
  38.  
  39. Everyone is granted permission to copy, modify and redistribute
  40. GNU CC, but only under the conditions described in the
  41. GNU CC General Public License.   A copy of this license is
  42. supposed to have been given to you along with GNU CC so you
  43. can know your rights and responsibilities.  It should be in a
  44. file named COPYING.  Among other things, the copyright notice
  45. and this notice must be preserved on all copies.  
  46. */
  47.  
  48.  
  49. #ifndef _TimeSchedulerdefs_h
  50. #define _TimeSchedulerdefs_h 1
  51.  
  52. #include "Thread.h"
  53.  
  54. class TimeScheduler {
  55.     Thread *pThread;
  56.     double pTime;
  57. public:
  58.     TimeScheduler();
  59.     TimeScheduler(Thread *p);
  60.     TimeScheduler(Thread *p, double when);
  61.     operator==(TimeScheduler &p);
  62.     operator<=(TimeScheduler &p);
  63.     Thread *thread();
  64.     double time();
  65. };
  66.  
  67. inline Thread*
  68. TimeScheduler::thread()
  69. {
  70.     return(pThread);
  71. }
  72.  
  73. inline double
  74. TimeScheduler::time()
  75. {
  76.     return(pTime);
  77. }
  78.  
  79. inline TimeScheduler::TimeScheduler()
  80. {
  81.     pThread = 0;
  82.     pTime = 0;
  83. }
  84.  
  85. inline TimeScheduler::TimeScheduler(Thread *p)
  86. {
  87.     pThread = p;
  88.     pTime = 0;
  89. }
  90.  
  91. inline TimeScheduler::TimeScheduler(Thread *p, double w)
  92. {
  93.     pThread = p;
  94.     pTime = w;
  95. }
  96.  
  97. inline int TimeScheduler::operator==(TimeScheduler &p)
  98. {
  99.     return( (pTime == p.pTime)
  100.        && (pThread -> priority() == (p.thread() -> priority())));
  101. }
  102.  
  103. inline int TimeScheduler::operator<=(TimeScheduler &p)
  104. {
  105.     return(
  106.        (pTime <  p.pTime)
  107.        || ( (pTime == p.pTime)
  108.            && (pThread -> priority() <= (p.thread() -> priority()))) );
  109. }
  110.  
  111. // equality operator
  112. #ifndef TimeSchedulerEQ
  113. #define TimeSchedulerEQ(a, b)  ((a) == (b))
  114. #endif
  115.  
  116. // less-than-or-equal
  117. #ifndef TimeSchedulerLE
  118. #define TimeSchedulerLE(a, b)  ((a) <= (b))
  119. #endif
  120.  
  121. // comparison : less-than -> < 0; equal -> 0; greater-than -> > 0
  122. #ifndef TimeSchedulerCMP
  123. #define TimeSchedulerCMP(a, b) ( ((a) <= (b))? (((a) == (b))? 0 : -1) : 1 )
  124. #endif
  125.  
  126. // hash function
  127. #ifndef TimeSchedulerHASH
  128. extern unsigned int hash(TimeScheduler&);
  129. #define TimeSchedulerHASH(x)  hash(x)
  130. #endif
  131.  
  132. // initial capacity for structures requiring one
  133.  
  134. #ifndef DEFAULT_INITIAL_CAPACITY
  135. #define DEFAULT_INITIAL_CAPACITY 100
  136. #endif
  137.  
  138.  
  139. #endif
  140. @
  141.